package com.wxp.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import com.wxp.entity.Resource;

@Repository
public interface  ResourceDao extends JpaRepository<Resource, String>,JpaSpecificationExecutor<Resource> {
    
	Resource findFirstByoperator(String operator);
	List<Resource> findAll();
	
	 @Query(value ="select a.operator_  ,a.module_ ,a.permission_ ,a.url_,a.operator_name_ ,a.operator_type_  ,a.parent_operator_ , (case when b.permission_id_ is not null then 'true' else 'false' end) as checked_ from t_resource a left join (select * from t_permission c where c.role_code_ = ?1) b on a.operator_ = b.operator_id_ ",nativeQuery = true)
	 List<Resource> findAll(String roleCode);
}
